class Solution {
public:
    int result = 1000;
    TreeNode* pre = NULL;
    void traversal(TreeNode* cur){
      if(cur == NULL) return;
      traversal(cur->left);
      if(pre != NULL){
        result = min(result,cur->val - pre->val);
      }
      pre = cur;
      traversal(cur->right);
    }
    int getMinimumDifference(TreeNode* root) {
        traversal(root);
        return result;
    }
};
